<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 
      循环优化：
        一些不变的数据，可以在循环外定义，在到循环中使用
    -->
    <script>
      /* var test = () => {
        var arr = ["zce", 38, "前端"];
        var i;
        for (i = 0; i < arr.length; i++) {
          console.log(arr[i]);
        }
      };

      test(); */

      /* var test1 = () => {
        var arr = ["zce", 38, "前端"];
        var i;
        var len = arr.length;
        for (i = 0; i < len; i++) {
          console.log(arr[i]);
        }
      };

      test1(); */

      var test2 = () => {
        var arr = ["zce", 38, "前端"];
        var len = arr.length;
        while (len--) {
          console.log(arr[len]);
        }
      };

      test2();
    </script>
  </body>
</html>
